home *** CD-ROM | disk | FTP | other *** search
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Jamba code template for $$JAMBA_CLASSNAME$$Obj
- * trwidobj.java
- */
- $$ENDIF
-
- // All Jamba objects are located in the objects package
- package Aimtech.objects;
-
- // Standard Jamba imports
- import java.lang.*;
- import java.awt.*;
- import java.util.*;
- import Aimtech.utils.*;
- import Aimtech.effects.*;
- import Aimtech.smartpage.*;
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Implementation of Jamba $$JAMBA_CLASSNAME$$Obj object
- */
- $$ENDIF
-
- public class $$JAMBA_CLASSNAME$$Obj extends WidgetObj implements Runnable
- {
- // Used in objStart to check if previously stopped
- private boolean bStopped = false;
-
- // This object's thread
- Thread thread = null;
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called once, and only once, when object is first loaded. Use
- * to perform one time object initialization
- */
- $$ENDIF
- public void objLoad ()
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- super.objLoad();
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called each time the Jamba page containing the object is displayed. Use
- * to allocate object resources. These resources should be freed in
- * objFlush
- */
- $$ENDIF
-
- public final void objPrepare()
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- // Create the component for the object.
- if (theComponent == null)
- {
- theComponent = (Component)new TemplateWidgetImp(this);
- }
-
- super.objPrepare();
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called each time the Jamba page containing the object is removed from
- * the list of recently accessed Jamba pages. Use to free resources
- * allocated by object.
- */
- $$ENDIF
-
- public void objFlush()
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- super.objFlush();
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called in response to several events including the object being made
- * visible and the HTML page containing the object being redisplayed.
- */
- $$ENDIF
- public void objStart()
- {
- // If object stopped by objStop(), restart it here
- if (bStopped)
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- start();
- bStopped = false;
- }
-
- super.objStart();
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called in response to several events including the object being made
- * not visible and the HTML page containing the object being changed
- * within a web browser such that another HTML page can be displayed.
- * Use to cease any ongoing object activity.
- */
- $$ENDIF
- public void objStop()
- {
- if (!bStopped)
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- stop();
- bStopped = true;
- }
-
- super.objStop();
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called when object properties are set or changed
- */
- $$ENDIF
- public synchronized void objSetProp(String name, String value)
- {
- if (name.equals("property1"))
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- }
-
- else if (name.equals("property2"))
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- }
-
- // Default property handling
- else super.objSetProp(name, value);
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called to retrieve the current value of an object property.
- */
- $$ENDIF
- public synchronized String objGetProp(String name)
- {
- // If object does not track a property value in member variables or
- // does not modify properties without updating the object's property
- // list, it can simply allow the default property handling to occur
- // and not have a case for it in the following code
- if (name.equals("property1"))
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- }
-
- else if (name.equals("property2"))
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- }
-
- return (super.objGetProp(name));
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Called when an object methods has been called within a ToDo list.
- */
- $$ENDIF
- public synchronized boolean objDoMethod(String method, Vector args)
- {
- if (method.equals ("method1"))
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- }
- else if (method.equals ("method2"))
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- }
- else
- {
- return (super.objDoMethod(method, args));
- }
-
- // The method was handled
- return (true);
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Standard start method used by Jamba objects
- */
- $$ENDIF
- public void start ()
- {
- if (thread == null)
- {
- thread = new Thread (this);
- }
-
- if (!thread.isAlive())
- {
- thread.start();
- }
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Standard stop method used by Jamba objects
- */
- $$ENDIF
- public void stop ()
- {
- if (thread != null)
- {
- Thread tmp = thread;
- thread = null;
- tmp.stop();
- }
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Object's run method for it's thread
- */
- $$ENDIF
- public void run ()
- {
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- // Must be last line in method
- stop();
- }
-
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Jamba code for TemplateWidgetImp. This is the actual Java componet
- * created for the object. You need to supply all painting and event
- * handling.
- *
- * This class can be modified to extend other Java components besides
- * $$JAMBA_CLASSEXTEND$$.
- */
- $$ENDIF
- class TemplateWidgetImp extends $$JAMBA_CLASSEXTEND$$
- {
- // Handle to the Jamba object
- private BaseObj obj;
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Constructor to create component
- */
- $$ENDIF
- public TemplateWidgetImp (BaseObj obj)
- {
- // Create the component
- super();
-
- // Save a handle to the Jamba object
- this.obj = obj;
-
- $$IF(JAMBA_TODOCOMMENTS)
- //# TODO - Insert custom code here
- $$ENDIF
- }
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Sample paint method used to validate object creation
- * For a canvas class you can override the paint member like this
- * public void paint (Graphics g)
- * {
- * g.drawString ("Object Is Alive", 10, 20);
- * }
- */
- $$ENDIF
-
- $$IF(JAMBA_EXPLCOMMENTS)
- /**
- * Handle input events and generate corresponding Jamba events
- */
- $$ENDIF
- public boolean handleEvent(Event event)
- {
- switch (event.id)
- {
- //# Sample event handling
- case Event.MOUSE_UP:
- obj.processAction ("click");
- break;
-
- default:
- return (false);
- }
-
- return (true);
- }
- }
-